package com.example.controller;

import com.example.framwork.code.CodeConst;
import com.example.framwork.result.ProjectResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/helloWorld")
public class HelloWorldController {

    //方法同时支持get，post
    @RequestMapping(value = "/test", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String test(HttpServletRequest request) {
        return "ok";
    }

    @RequestMapping(value = "/hello", method = {RequestMethod.GET, RequestMethod.POST})
    public ProjectResult hello() {
        return new ProjectResult(CodeConst.SUCCESS, "this is ok", null);
    }
}
